# 导包
import requests
import unittest
from utils import public
from api.login import login_Api
from parameterized import parameterized

# 创建测试用例



class login_Test(unittest.TestCase):

    def setUp(self):
        self.login_Api = login_Api()
        self.sission = requests.Session()

    def tearDown(self):
        self.sission.close()

    @parameterized.expand(login_Api.build_data())
    def test01(self,mobile,password,success,code,message,xycode):
        response = login_Api().login(self.sission,mobile,password)

        # self.assertEqual(xycode, response.status_code)
        # self.assertEqual(success, response.json().get("success"))
        # self.assertEqual(code, response.json().get("code"))
        # self.assertIn(message, response.json().get("message"))
        public(self,response,xycode,success,code,message)

        TOKEN =  "Bearer " + str(response.json().get("data"))
        print(TOKEN)
        file = "./tools/app.txt"
        with open(file,"w") as f:
            f.write(TOKEN)






